home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / source / snip9503 / pcnvrt.c < prev    next >
C/C++ Source or Header  |  1995-03-14  |  645b  |  23 lines

  1. /*
  2. **  demo code for converting Pascal strings to/from C strings
  3. **
  4. **  public domain by Bob Stout
  5. */
  6.  
  7. #include <string.h>
  8.  
  9. typedef unsigned char UCHAR;
  10.  
  11. #define P2Cconvert(s) {UCHAR n = *(s); memmove((s), &(s)[1], n); s[n] = '\0';}
  12. #define C2Pconvert(s) {int n = strlen(s); memmove(&(s)[1], (s), n); *(s) = n;}
  13.  
  14. #if (0)                             /* Demo code fragment follows */
  15.  
  16.       char string[81];
  17.  
  18.       fgets(string, 81, inFile);    /* get 80-char pascal string  */
  19.       P2Cconvert(string);           /* convert it in place        */
  20.       C2Pconvert(string);           /* convert back               */
  21.  
  22. #endif 
  23.